/* 二分
* 
* 本题:
    给定avg 判断是否存在一个方案，使其平均值>=avg
    ai-=avg -> si
    是否存在长度>=F的一段和>=0

*/

#define DEBUG
#pragma GCC optimize("O1,O2,O3,Ofast")
#pragma GCC optimize("no-stack-protector,unroll-loops,fast-math,inline")
#pragma GCC target("avx,avx2,fma")
#pragma GCC target("sse,sse2,sse3,sse4,sse4.1,sse4.2,ssse3")

#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
const int N = 1e5+10;

int n, F;
double a[N], s[N];

bool check(double avg)
{
    for(int i = 1; i <= n; i++) s[i] = s[i-1]+a[i]-avg; //计算每个元素-avg的前缀和
    double mins = 0;
    for(int k = F; k <= n; k++){
        mins = min(mins, s[k-F]); //找到最小前缀和
        if(s[k] >= mins) return true; //存在一段前缀和>=0,即avg有效
    }
    return false;
}

signed main()
{
    #ifdef DEBUG
        freopen("./in.txt", "r", stdin);
    #else
        ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #endif
    
    cin >> n >> F;
    double l = 0, r = 0;
    for(int i = 1; i <= n; i++)
    {
        cin >> a[i];
        r = max(r, a[i]);
    }

    while(r-l > 1e-5) //[l,r]为有效解区间
    {
        double mid = (l+r)/2;
        if(check(mid)) l = mid;
        else r = mid;
    }

    printf("%d\n", (int)(r * 1000));
    return 0;
}